home *** CD-ROM | disk | FTP | other *** search
/ Aminet 6 / Aminet 6 - June 1995.iso / Aminet / dev / e / sortobj.readme < prev    next >
Encoding:
Text File  |  1995-04-27  |  8.2 KB  |  261 lines

  1. Short:    Abstract sortobj object for Amiga E
  2. Author:   Joseph E. Van Riper III
  3. Uploader: jvanriper@uncavx.unca.edu
  4. Type:     dev/e
  5.  
  6. Long:
  7.  
  8. SortObj for Amiga E
  9.  
  10. This set of objects was created by Trey Van Riper of the
  11. Cheese Olfactory Workshop for use with Amiga E.  Wear it in
  12. good health.
  13.  
  14. This archive has SortObj, String, Integer, and Address.
  15.  
  16. PURPOSE
  17. -------
  18.  
  19. To supply the Amiga E community with an extensible OT class
  20. that might help provide for some extreme functionality in
  21. the future through reuse (for example, I will very likely
  22. create a sorted list class based on this object class) I
  23. took the trouble to create SortObj.
  24.  
  25. The basic idea behind 'SortObj' is to have a single object
  26. from which other objects can be derived that might allow for
  27. sorting in a list or somesuch.  I have not yet made such a
  28. list, but these objects will still be useful to OT
  29. developers working in Amiga E.
  30.  
  31. NOTE: As this is an abstract class, it's extremely
  32. low-level.  Initially, this object looks on the face of it
  33. to be darned useless, but as people start deriving more
  34. objects from this one, its flexibility will become more
  35. obvious.
  36.  
  37. I am hoping this will help encourage people to release OT
  38. objects to help extend Amiga E's usefulness.
  39.  
  40. HOW TO USE
  41. ----------
  42.  
  43. Well.. I suppose I'd best give the SortObj ShowModule output
  44. first:
  45.  
  46. ShowModule v1.9 (c) 1992 $#%!
  47. now showing: "sortobj.m"
  48. NOTE: don't use this output in your code, use the module instead.
  49.  
  50. /* this module contains 620 bytes of code! */
  51.  
  52. (---) OBJECT sortobj
  53.         new(a)
  54.         opts(a)
  55.         init()
  56.         lt(a)
  57.         gt(a)
  58.         et(a)
  59.         le(a)
  60.         ge(a)
  61.         ne(a)
  62.         cmp(a)
  63.         set(a)
  64.         write()
  65.         get()
  66.     id()
  67.         end()
  68. (---) ENDOBJECT     /* SIZEOF=4 */
  69.  
  70. -- new(a)
  71.  
  72.    This method is intended to be an intializer.  You can
  73.    pass options to it; I would recommend one passes an Amiga
  74.    E list rather than a simple value; this will help keep
  75.    your code extensible.  Basically, one shouldn't have to
  76.    worry about creating their own new() methods as this one
  77.    calls 'init()' and 'opts()'.
  78.  
  79. -- opts(a)
  80.  
  81.    This method allows you to pass special options to the
  82.    object, in case your object requires several things to be
  83.    set at various values (examine the Address object).
  84.  
  85. -- init()
  86.  
  87.    This method is intended to help you initialize the
  88.    object, in case it needs it.  Maybe you need to NEW some
  89.    pointers or something.
  90.  
  91. -- cmp(a)
  92.  
  93.    This method is VERY important... to get the most out of
  94.    sortobj, you will want to define this.  Basically, this
  95.    should perform a comparison between something within your
  96.    object, and something within object 'a' (which should be
  97.    the same as your own object).
  98.  
  99.    Not that the above makes a lot of sense.
  100.  
  101.    Generally, 'a' is supposed to be an instance of the
  102.    object you're creating.  'cmp()' is supposed to compare
  103.    something within that instance with something inside your
  104.    'self' instance.
  105.  
  106.    It should return '1' if the 'self' value is greater than
  107.    the 'a' value, '0' if the two are equal, and '-1' if
  108.    'self' is less than the 'a' value.
  109.  
  110.    Then, a whole bunch of other functions will become
  111.    enabled for your procedure... lt()/gt()/le()/ge()/ne()/et()
  112.    will all instantly start working for you.
  113.  
  114.    I recommend you try to make this function work as quickly
  115.    as possible, as in some cases it might be called twice
  116.    (eg ge() and le()).
  117.  
  118. -- lt(a)
  119.  
  120.    This tests to see if self is less than a.
  121.  
  122. -- gt(a)
  123.  
  124.    This tests to see if self is greater than a.
  125.  
  126. -- et(a)
  127.  
  128.    This tests to see if self is equal to a.
  129.  
  130. -- le(a)
  131.  
  132.    This tests to see if self is less than or equal to a.
  133.  
  134. -- ge(a)
  135.  
  136.    This tests to see if self is greater than or equal to a.
  137.  
  138. -- ne(a)
  139.  
  140.    This tests to see if self is not equal to a.
  141.  
  142. -- write()
  143.  
  144.    This method should return a string to be written by
  145.    someone else.  Perhaps, in the far future, this class
  146.    could be extended by creating an output object that could
  147.    be used by sortobj or something.. in the meantime, you
  148.    can try using this.
  149.  
  150.    Basically, make sure this method returns something you
  151.    could WriteF().
  152.  
  153. -- get()
  154.  
  155.    This method should return the data within the object.
  156.    This isn't exactly easy to judge in the case of objects
  157.    with multiple members (such as the Address object), but
  158.    its useful for such things as strings and integers.
  159.    Perhaps this could return an OBJECT with normal pointers
  160.    to strings and stuff like that... it'll have to be your
  161.    own call how to use it, but you hopefully get the general
  162.    drift.  Use the other objects derived from sortobj as a
  163.    guide.
  164.  
  165. -- id()
  166.  
  167.    This method returns a number describing the kind of
  168.    object it is.  This can be handy for making lists of
  169.    objects of unknown types.
  170.  
  171. -- end()
  172.  
  173.    Of course, this is the deallocator.  This function will
  174.    be called when someone ENDs the object, so it should be
  175.    useful for something <grin>.
  176.  
  177. SO WHAT, WHO CARES
  178. ------------------
  179.  
  180. I know it doesn't seem like such a big deal to have these
  181. objects, especially since I'm not yet supplying a sorted
  182. list, but consider how useful this would be when used with
  183. something like queuestack (yeah, I know, cheap
  184. advertisement, but hey, it's a cheap product)... then again,
  185. someone else might beat me to the creation of an object
  186. oriented sorted list!
  187.  
  188. You could store pointers to different kinds of sortobjs
  189. within queuestack, dropping them into the queuestack
  190. willy-nilly, without any idea what they might be, then pull
  191. them out again as needed, id()ing them to figure out what
  192. they are.
  193.  
  194. You could even iterate through the queuestack, write()ing
  195. the values to some kind of variable to be printed out in a
  196. WriteF() or something, without having to worry about what
  197. the object in the queuestack is!
  198.  
  199. I've taken the trouble to provide you with a string and
  200. integer object as subclasses of sortobj, as well as an
  201. example of a more complex object 'address'.  Still to be
  202. written are a float and fraction object.
  203.  
  204. The string and integer classes need further work; the string
  205. class should have some means by which someone could append
  206. new strings to it, as well as number conversions and all
  207. that happy stuff (basically, all the various Amiga
  208. Efunctions put into the class itself), while the integer
  209. object could use various functions to handle arithmatic
  210. matters.
  211.  
  212. In fact, the entire integer class will be reworked in the
  213. future to be derived from a higher abstract class 'number' that
  214. I'm going to create sometime later... but I wanted to get a
  215. quick version out in the meantime.
  216.  
  217. DISTRIBUTION
  218. ------------
  219.  
  220. You are granted full rights to use and distribute this.
  221. I am not requiring money for its use.  In fact, I encourage
  222. as many people as possible to use this, and to possibly
  223. extend this as much as possible.  Hell, fix any screwup you
  224. find!
  225.  
  226. Basically, this is Public Domain; even the source has been
  227. made available so you can have yet another example of OT
  228. programming.  I ask that you do not modify the source code
  229. under my name; let me be responsible for my own mistakes,
  230. nobody else's.  I also ask you do not take credit for work
  231. I've done; OT programming seems to be tricky for some folks
  232. to handle, and I want to be sure to get the credit where
  233. it's due.
  234.  
  235. Consider this a contribution to the Amiga E community to
  236. encourage the development of object tools in the Amiga E
  237. language.
  238.  
  239. As ever, Wouter van Ootmerson has full permission to include
  240. this in his next release of Amiga E, as he sees fit, without
  241. having to pay me anything but credit.
  242.  
  243.  
  244. ============================= Archive contents =============================
  245.  
  246. Original  Packed Ratio    Date     Time    Name
  247. -------- ------- ----- --------- --------  -------------
  248.     2275     802 64.7% 11-Feb-95 16:49:56  address.e
  249.     2114     757 64.1% 11-Feb-95 16:39:10  address.m
  250.      923     471 48.9% 11-Feb-95 16:50:24  integer.e
  251.      636     361 43.2% 11-Feb-95 16:36:42  integer.m
  252.     2601    1018 60.8% 11-Feb-95 16:51:12  sortobj.e
  253.      916     352 61.5% 11-Feb-95 16:46:02  sortobj.m
  254.     7527    3260 56.6% 11-Feb-95 16:49:22  sortobj.readme
  255.     1682     738 56.1% 11-Feb-95 16:38:56  string.e
  256.     1202     578 51.9% 11-Feb-95 16:39:08  string.m
  257.     5840    2357 59.6% 11-Feb-95 16:41:00  test
  258.     1447     511 64.6% 11-Feb-95 16:40:56  test.e
  259. -------- ------- ----- --------- --------
  260.    27163   11205 58.7% 13-Feb-95 11:43:50   11 files
  261.